Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Creating a Track Time Table

Listing 17 illustrates how to use the MakeTrackTimeTable function to create a time table for the tracks in a movie.

Listing 17 Creating a time table for movie tracks

OSErr       theErr = noErr;
WindowPtr   movieWindow = nil;
Movie       theMovie = nil;
Track       theTrack;
long        trackCount,
            trackIndex,
            retDataRefSkew;
TimeValue   startTime,
            endTime,
            timeIncrement;
short       firstDataRefIndex,
            lastDataRefIndex;
Handle      offsets,
            offsetsSet [32];

err = GetDisplayedMovie (&movieWindow, &theMovie);

timeIncrement = GetMovieTimeScale (theMovie);
firstDataRefIndex = -1;
lastDataRefIndex = -1;
trackCount = GetMovieTrackCount (theMovie);

for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
    theTrack = GetMovieIndTrack (theMovie, trackIndex);
    offsets = NewHandle (0);
    offsetsSet [trackIndex - 1] = offsets;
    startTime = GetTrackOffset (theTrack);
    endTime = GetTrackDuration (theTrack);
    err = MakeTrackTimeTable (theTrack, (long **) offsets,
                startTime, endTime, timeIncrement,
                firstDataRefIndex, lastDataRefIndex, &retDataRefSkew);
}

// dispose handles
for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
    DisposeHandle (offsetsSet [trackIndex - 1]);
}

© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |